package com.yanqu.road.entity.grandchild;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_u_grand_child")
public class GrandChildData extends DataObject {
    @FieldTypeAnnotation(select = true, update = true)
    private long userId;
    @FieldTypeAnnotation(update = true)
    private String id;
    @FieldTypeAnnotation
    private int appearanceId;
    @FieldTypeAnnotation
    private String nickName;
    @FieldTypeAnnotation
    private int lv;
    @FieldTypeAnnotation
    private int occupation;
    @FieldTypeAnnotation
    private List<Integer> flairList = new ArrayList<>();
    private List<Integer> baseFlairList = new ArrayList<>();
    @FieldTypeAnnotation
    private List<Integer> talentList = new ArrayList<>();
    @FieldTypeAnnotation
    private List<Integer> optionalList = new ArrayList<>();
    @FieldTypeAnnotation
    private int reTalentTimes;
    @FieldTypeAnnotation
    private int archaeus;
    @FieldTypeAnnotation
    private long archaeusLastRecoverTime;
    @FieldTypeAnnotation
    private BigInteger earnSpeed = BigInteger.ZERO;
    @FieldTypeAnnotation
    private int patronsId;
    @FieldTypeAnnotation
    private int sex;
    @FieldTypeAnnotation
    private int maxLv;
    @FieldTypeAnnotation
    private int quality;
    private int baseQuality;
    @FieldTypeAnnotation
    private int beautyId;
    @FieldTypeAnnotation
    private int trainExp;
    private int title;
    private int professionId;
    private int affinityPatronsId;
    private int hadExam; // 0未参加，1参加

    // 不入库
    private long reqJoinExamTime = 0L;
    private Map<Integer, Integer> addiMap = new ConcurrentHashMap<>(); // 技能加成值：Map<技能类型，加成值>

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (!Objects.equals(this.userId, userId)) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        if (!Objects.equals(this.id, id)) {
            this.id = id;
            setUpdateOption();
        }
    }

    public int getAppearanceId() {
        return appearanceId;
    }

    public void setAppearanceId(int appearanceId) {
        if (!Objects.equals(this.appearanceId, appearanceId)) {
            this.appearanceId = appearanceId;
            setUpdateOption();
        }
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        if (!Objects.equals(this.nickName, nickName)) {
            this.nickName = nickName;
            setUpdateOption();
        }
    }

    public int getLv() {
        return lv;
    }

    public void setLv(int lv) {
        if (!Objects.equals(this.lv, lv)) {
            this.lv = lv;
            setUpdateOption();
        }
    }

    public int getOccupation() {
        return occupation;
    }

    public void setOccupation(int occupation) {
        if (!Objects.equals(this.occupation, occupation)) {
            this.occupation = occupation;
            setUpdateOption();
        }
    }

    public List<Integer> getFlairList() {
        return flairList;
    }

    public void setFlairList(List<Integer> flairList) {
        if (!Objects.equals(this.flairList, flairList)) {
            this.flairList = flairList;
            setUpdateOption();
        }
    }

    public List<Integer> getTalentList() {
        return talentList;
    }

    public void setTalentList(List<Integer> talentList) {
        if (!Objects.equals(this.talentList, talentList)) {
            this.talentList = talentList;
            setUpdateOption();
        }
    }

    public List<Integer> getOptionalList() {
        return optionalList;
    }

    public void setOptionalList(List<Integer> optionalList) {
        if (!Objects.equals(this.optionalList, optionalList)) {
            this.optionalList = optionalList;
            setUpdateOption();
        }
    }

    public int getReTalentTimes() {
        return reTalentTimes;
    }

    public void setReTalentTimes(int reTalentTimes) {
        if (!Objects.equals(this.reTalentTimes, reTalentTimes)) {
            this.reTalentTimes = reTalentTimes;
            setUpdateOption();
        }
    }

    public int getArchaeus() {
        return archaeus;
    }

    public void setArchaeus(int archaeus) {
        if (!Objects.equals(this.archaeus, archaeus)) {
            this.archaeus = archaeus;
            setUpdateOption();
        }
    }

    public long getArchaeusLastRecoverTime() {
        return archaeusLastRecoverTime;
    }

    public void setArchaeusLastRecoverTime(long archaeusLastRecoverTime) {
        if (!Objects.equals(this.archaeusLastRecoverTime, archaeusLastRecoverTime)) {
            this.archaeusLastRecoverTime = archaeusLastRecoverTime;
            setUpdateOption();
        }
    }

    public BigInteger getEarnSpeed() {
        return earnSpeed;
    }

    public void setEarnSpeed(BigInteger earnSpeed) {
        if (!Objects.equals(this.earnSpeed, earnSpeed)) {
            this.earnSpeed = earnSpeed;
            setUpdateOption();
        }
    }

    public int getPatronsId() {
        return patronsId;
    }

    public void setPatronsId(int patronsId) {
        if (!Objects.equals(this.patronsId, patronsId)) {
            this.patronsId = patronsId;
            setUpdateOption();
        }
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        if (!Objects.equals(this.sex, sex)) {
            this.sex = sex;
            setUpdateOption();
        }
    }

    public int getMaxLv() {
        return maxLv;
    }

    public void setMaxLv(int maxLv) {
        if (!Objects.equals(this.maxLv, maxLv)) {
            this.maxLv = maxLv;
            setUpdateOption();
        }
    }

    public int getQuality() {
        return quality;
    }

    public void setQuality(int quality) {
        if (!Objects.equals(this.quality, quality)) {
            this.quality = quality;
            setUpdateOption();
        }
    }

    public int getBeautyId() {
        return beautyId;
    }

    public void setBeautyId(int beautyId) {
        this.beautyId = beautyId;
    }

    public int getTrainExp() {
        return trainExp;
    }

    public void setTrainExp(int trainExp) {
        if (!Objects.equals(this.trainExp, trainExp)) {
            this.trainExp = trainExp;
            setUpdateOption();
        }
    }

    public int getTitle() {
        return title;
    }

    public void setTitle(int title) {
        if (!Objects.equals(this.title, title)) {
            this.title = title;
            setUpdateOption();
        }
    }

    public int getHadExam() {
        return hadExam;
    }

    public void setHadExam(int hadExam) {
        if (!Objects.equals(this.hadExam, hadExam)) {
            this.hadExam = hadExam;
            setUpdateOption();
        }
    }

    public int getProfessionId() {
        return professionId;
    }

    public void setProfessionId(int professionId) {
        if (!Objects.equals(this.professionId, professionId)) {
            this.professionId = professionId;
            setUpdateOption();
        }
    }

    public int getAffinityPatronsId() {
        return affinityPatronsId;
    }

    public void setAffinityPatronsId(int affinityPatronsId) {
        if (!Objects.equals(this.affinityPatronsId, affinityPatronsId)) {
            this.affinityPatronsId = affinityPatronsId;
            setUpdateOption();
        }
    }

    public long getReqJoinExamTime() {
        return reqJoinExamTime;
    }

    public void setReqJoinExamTime(long reqJoinExamTime) {
        this.reqJoinExamTime = reqJoinExamTime;
    }

    public Map<Integer, Integer> getAddiMap() {
        return addiMap;
    }

    public void setAddiMap(Map<Integer, Integer> addiMap) {
        this.addiMap = addiMap;
    }

    public List<Integer> getBaseFlairList() {
        return baseFlairList;
    }

    public void setBaseFlairList(List<Integer> baseFlairList) {
        if (!Objects.equals(this.baseFlairList, baseFlairList)) {
            this.baseFlairList = baseFlairList;
            setUpdateOption();
        }
    }

    public int getBaseQuality() {
        return baseQuality;
    }

    public void setBaseQuality(int baseQuality) {
        if (!Objects.equals(this.baseQuality, baseQuality)) {
            this.baseQuality = baseQuality;
            setUpdateOption();
        }
    }

    public GrandChildData clone() {
        GrandChildData clone = new GrandChildData();
        clone.setUserId(this.userId);
        clone.setId(this.id);
        clone.setAppearanceId(appearanceId);
        clone.setNickName(nickName);
        clone.setLv(lv);
        clone.setOccupation(occupation);
        clone.setFlairList(new ArrayList<>(flairList));
        clone.setTalentList(new ArrayList<>(talentList));
        clone.setOptionalList(new ArrayList<>(optionalList));
        clone.setReTalentTimes(reTalentTimes);
        clone.setArchaeus(archaeus);
        clone.setArchaeusLastRecoverTime(archaeusLastRecoverTime);
        clone.setEarnSpeed(earnSpeed);
        clone.setPatronsId(patronsId);
        clone.setSex(sex);
        clone.setMaxLv(maxLv);
        clone.setQuality(quality);
        clone.setBeautyId(beautyId);
        clone.setTrainExp(trainExp);
        clone.setTitle(title);
        clone.setProfessionId(professionId);
        clone.setAffinityPatronsId(affinityPatronsId);
        clone.setReqJoinExamTime(reqJoinExamTime);
        clone.setAddiMap(addiMap);
        clone.setBaseFlairList(baseFlairList);
        clone.setBaseQuality(baseQuality);
        clone.setHadExam(hadExam);
        return clone;
    }

    public int AllBaseFlair() {
        return baseFlairList.stream().mapToInt(Integer::intValue).sum();
    }

    /**
     * 获取总天资
     * @return
     */
    public int getAllFlair() {
        return this.flairList.stream().mapToInt(Integer::intValue).sum();
    }
}
